package com.aqie.demo.utils;

import com.aqie.demo.enter.HkEnter;
import com.aqie.demo.enter.R;
import com.ejlchina.okhttps.HTTP;
import com.ejlchina.okhttps.HttpResult;
import com.ejlchina.okhttps.jackson.JacksonMsgConvertor;
import lombok.extern.slf4j.Slf4j;
import okhttp3.MediaType;

import java.util.List;


/**
 * @Author aqie
 * @Date 2021/12/9 16:22
 * @desc 网络请求工具类
 */
@Slf4j
public class HttpUtils {
    private static HTTP http = HTTP.builder()
            .baseUrl(PropertyUtils.getProperties("url"))
            .addMsgConvertor(new JacksonMsgConvertor())
            .build();
    public static final MediaType mediaType = MediaType.parse("application/json;charset=utf-8");

    public static Boolean doPost(String url, List<HkEnter> list){
        R json = http.sync(url)
                .setBodyPara(list)
                .bodyType("json")
                .addHeader("Content-Type", "application/json")
                .post().getBody().toBean(R.class);
        return json.isSuccess();
    }
}
